package com.neusoft.neumooc.controller.front;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.neusoft.core.common.BaseController;
import com.neusoft.core.common.conf.Params;
import com.neusoft.neumooc.service.front.HomeIndexService;
import com.neusoft.neumooc.vo.ContentVO;

@Controller
@RequestMapping(value = "/fronthome")
public class HomeIndexController extends BaseController {
	@Autowired
	HomeIndexService homeIndexService;;

	/**
	 * @Title: fronthome
	 * @Description: 进入主页面
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "index")
	public String fronthome(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		return "front/home";
	}

	/**
	 * @Title: getHome
	 * @Description: 加载首页信息
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getHome")
	@ResponseBody
	public Map<String, Object> getHome(HttpServletRequest request,
			HttpServletResponse response) {
		List<ContentVO> picListHome = homeIndexService.queryHomeList();
		String queryLink = homeIndexService.queryLink();
		Map<String, Object> resMap = new HashMap<String, Object>();
		resMap.put("queryLink", queryLink);
		resMap.put(Params.RET_OBJ, picListHome);
		return resMap;
	}

	/**
	 * @Title: searchInfo
	 * @Description: 进入搜索页面
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/searchInfo")
	public String searchInfo(Model model, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String search = request.getParameter("search");
		model.addAttribute("search", search);
		return "front/searchInfo";
	}
}
